import http from "../../http";
interface User {
    id: string;
    college: string;
    sex: string;
    age: string;
    score: Number;
    name: string;
    hege?:string;
  }
let month={
    state:{
        tableData:[],
        listleave:[]
    },
    mutations:{
        GETLIST(state:any,data: any){
            state.tableData=data
            state.tableData.forEach((item: { hege: string; score: number; })=>{
                item.hege=item.score>=60 ? "合格":"不合格"
            })
        },
        GETLEAVE(state: any,data: any){
            state.listleave=data
        },
        addList(state:any,data:any){
            state.tableData.unshift(data)
            state.tableData.forEach((item: { hege: string; score: number; })=>{
                item.hege=item.score>=60 ? "合格":"不合格"
            })
        },
        // 更新
        updateList(state:any,data:any){
            console.log(data.list)
            state.tableData.splice(data.index,1,data.list)
            state.tableData.forEach((item: { hege: string; score: number; })=>{
                item.hege=item.score>=60 ? "合格":"不合格"
            })
        }
    },
    actions:{
        // 获取人员信息
        async getStudent(context:any){
            let res=await http.get("/list-student")
            if(res.status==200){
                context.commit("GETLIST",res.data)
            }else{
                console.log("错误")
            }
        },
        // 获取请假人员
        async getLeave(context:any){
            let res=await http.get("/leave")
            if(res.status==200){
                context.commit("GETLEAVE",res.data)
            }else{
                console.log("错误")
            }
        }
    },
    getters:{

    }
}
export default month


